package Thread_lock;

/**
 * Created with IDEA
 * author:ju bai
 * Date:2021/5/29
 * Time:19:40
 * 可重入锁
 **/
public class Demo8 {

    //创建一把锁
    private static Object lock = new Object();

    public static void main(String[] args) {
        synchronized (lock) {
            System.out.println("第一次进入锁");
            synchronized (lock) {
                System.out.println("第二次进入锁");
            }
        }
    }
    //若两次都打印，说明它是可重入锁
}
